package com.ludomancy.starwave;

import java.awt.Point;
import java.util.Vector;

public class PortalShip extends Ship
{
	public PortalShip(Player owner, int px, int py)
	{
		super(owner, px, py);
		type = POR;
	}
	
	protected Point[] getFiringArc()
	{
		return new Point[0]; 
	}
	
	protected void receiveAttack(double damage)
	{
		// cannot be attacked
	}
		
	public boolean collide(Ship ship, Vector animations)
	{
		// teleport ship
		Ship twin = findTwin();
		ship.px = twin.px;
		ship.py = twin.py;
		animations.add(new PortalAnimation(this, (PortalShip)twin, ship ));
		return true;
	}
	
	private Ship findTwin()
	{
		for (int i = 0; i < Game.game.ships.size(); i++)
		{
			Ship ship = (Ship) Game.game.ships.elementAt(i);
			if(ship.type == type && ship != this)
			{
				return ship;
			}
		}
		return null;
	}
	
	public boolean isSolid()
	{
		return false;
	}

	protected boolean canMove()
	{
		return false;
	}

	public String getDescription()
	{
		return "Portal moves ships into its twin portal";
	}
}
